<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:c="http://xmlns.jcp.org/jsf/composite"
	xmlns:p="http://primefaces.org/ui">

<ui:decorate template="/jsp/WEB/pageLayout.xhtml">

	<ui:define name="centro">
		<p:tabView activeIndex="#{GerEntrBean.tabIndex}">
			<p:ajax event="tabChange" listener="#{GerEntrBean.onTabChange}" />

			<!-- ############################################################ -->
			<!-- Entrada - Vinculo de cliente x cartão -->
			<!-- ############################################################ -->
			<p:tab title="Entrada de Clientes" >
				<h:form id="formEntrada">
					<p:growl id="msgs" showDetail="true" />
					
					<p:panel id="pnlInputData"
						header="Informe os dados para entrada de cliente e vínculo de cartão"
						style="margin-top:1%">
					<p:focus context="pnlInputData" />
						<!-- *********************************************************** -->
						<!-- Cliente -->
						<!-- *********************************************************** -->

						<table cellpadding="0" cellspacing="0" border="0">
							<tr>
							
								<td style="align: left; height: 30px"><h:outputLabel
										for="MaskCPF" value="CPF:" /></td>
								<td style="align: left; height: 30px"><p:inputMask
										id="MaskCPF" style="margin-left:5px;width:95px" mask="999.999.999-99"
										value="#{GerEntrBean.entrCliente.cpf}" /></td>
								<td style="align: left; height: 30px"><p:commandButton
										id="searchUser" value="Buscar"
										style="margin-left:5px;width:80px" image="ui-icon-search"
										update="@formBloqueio" ajax="false" title="Consultar cliente"
										actionListener="#{GerEntrBean.btnValidadeCustomer}" /></td>
							
								<td style="align: right;"><h:outputLabel style="margin-left:-52px"
										for="Nome" value="Nome:" /></td>
								<td style="align: right;"><p:inputText style="margin-left:-60px;width:320px"
										id="Nome" value="#{GerEntrBean.entrCliente.name}" /></td>
					</tr>
							<tr>
								<td style="align: left; height: 30px"><p:outputLabel
										for="Tel" value="Telefone:" /></td>
								<td style="align: left; height: 30px"><p:inputMask id="Tel"
										style="margin-left:5px;width:95px" value="#{GerEntrBean.entrCliente.tel}"
										mask="(99) 99999-9999" /></td>
							
								<td style="align: right; height: 30px"><h:outputLabel style="margin-left:150px"
										for="Comanda" value="Nº cartão:" /></td>
								<td style="align: right; height: 30px"><p:inputText 
										id="Comanda" style="margin-left:10px;width:50px" label="Comanda"
										value="#{GerEntrBean.entrCartao.idCard}" /></td>
								<td style="align: right; height: 30px"><p:commandButton 
										id="searchCard" value="Validar"
										style="margin-left:10px;width:80px" image="ui-icon-info"
										update="@formBloqueio" ajax="false" title="Consultar Cartão"
										actionListener="#{GerEntrBean.btnValidateCard()}" /></td>
										
								<td style="align: left; height: 30px"><h:outputLabel style="margin-left:-155px"
										for="Credito" value="Valor do crédito:" >
									
										</h:outputLabel></td>
								<td style="align: left; height: 30px"><p:inputText 
										id="Credito" style="margin-left:-100px;width:50px" label="Credito"
										value="#{GerEntrBean.entrCartao.vlrCredito}" /></td>
							</tr>
						</table>
						<p:separator />
						<p:commandButton id="vincular" value="Vincular"
							update=":formEntrada" ajax="false" icon="ui-icon-disk"
							action="#{GerEntrBean.btnVincular()}" />
					</p:panel>

					<!-- ############################################################ -->
					<!-- Grid de Clientes tab ENTRADA-->
					<!-- ############################################################ -->

					<p:panel id="pnlGrid" header="Dados dos clientes ativos" style="margin-top:1%">


						<p:dataTable id="gridComanda" var="grid" 
							value="#{GerEntrBean.entrLstGrid}"
							emptyMessage="Nenhum cliente encontrado!" paginator="true"
							widgetVar="comandaTable"
							filteredValue="#{GerEntrBean.entrCliFiltrados}">
							<p:ajax event="rowSelect" />


							<p:column filterBy="#{grid.numerocomanda}" sortBy="numerocomanda"
								headerText="Nº Cartão" filterMatchMode="contains">
								<h:outputText value="#{grid.numerocomanda}" />
							</p:column>


							<p:column filterBy="#{grid.cpf}" sortBy="cpf"
								headerText="CPF do Cliente" filterMatchMode="contains">
								<h:outputText value="#{grid.cpf}" />
							</p:column>

							<p:column filterBy="#{grid.nome}" sortBy="nome"
								headerText="Nome do Cliente" filterMatchMode="contains">
								<h:outputText value="#{grid.nome}" />
							</p:column>

							<p:column filterBy="#{grid.idpedido}" sortBy="idpedido"
								headerText="Nº Pedido" filterMatchMode="contains">
								<h:outputText value="#{grid.idpedido}" />
							</p:column>


							<p:column filterBy="#{grid.datacriacao}" sortBy="datacriacao"
								headerText="Data" filterMatchMode="contains">
								<h:outputText value="#{grid.datacriacao}">
									<f:convertDateTime locale="pt_BR" pattern="dd/MM/yyyy" />
								</h:outputText>
							</p:column>

							<p:column filterBy="#{grid.horacriacao}" sortBy="horacriacao"
								headerText="Hora" filterMatchMode="contains">
								<h:outputText value="#{grid.horacriacao}" />
							</p:column>
							
							<p:column filterBy="#{grid.vlrCredito}" sortBy="vlrCredito"
								headerText="Valor do crédito" filterMatchMode="contains">
								<h:outputText value="#{grid.vlrCredito}" >
								<f:convertNumber pattern="#0.00" locale="pt_BR"/>
								</h:outputText>
							</p:column>


						</p:dataTable>
					</p:panel>
				</h:form>
			</p:tab>
			<!-- ############################################################ -->
			<!-- BLOQUEIO DE CARTÃO -->
			<!-- ############################################################ -->
			<p:tab title="Bloqueio de Cartão">
				<h:form id="formBloqueio">
					<p:growl id="msgs" showDetail="true" />
					
						<p:panel id="pnlInputData2"
						header="Informe os dados para entrada de cliente e bloqueio de cartão"
						style="margin-top:1%;width:80%">
					
						<!-- *********************************************************** -->
						<!-- Dados do Cartão -->
						<!-- *********************************************************** -->
						<table cellpadding="0" cellspacing="0" border="0">
							<tr>
								<td style="align: left; height: 30px"><h:outputLabel
										for="maskCPF2" value="CPF Cliente:*" /></td>
								<td style="align: left; height: 30px"><p:inputMask
										style="margin-left:5px;width:95px" mask="999.999.999-99" id="maskCPF2"
										value="#{GerBloqBean.bloqCliente.cpf}" /></td>
								<td style="align: left; height: 30px"><p:commandButton
										id="searchUser2" value="Buscar"
										style="margin-left:5px;width:80px" image="ui-icon-search"
										ajax="false" title="Consultar cliente"
										update="pnlListCardBloq"
										actionListener="#{GerBloqBean.btnBloqLoadCustomer()}" /></td>
							</tr>
							<tr>
								<td style="align: left; height: 30px"><h:outputLabel
										for="comanda2" value="Nº Cartão Novo:*" /></td>
								<td style="align: left; height: 30px"><p:inputText
										id="comanda2" style="margin-left:5px;width:50px" label="Comanda"
										value="#{GerBloqBean.bloqCartaoNov.idCard}" /></td>
								<td style="align: left; height: 30px"><p:commandButton
										id="searchCard2" value="Validar"
										style="margin-left:5px;width:80px" image="ui-icon-info"
										ajax="false" title="Consultar Cartão" update="pnlListCardBloq"
										actionListener="#{GerBloqBean.btnBloqLoadCard()}" /></td>
							</tr>
						</table>

						<!-- ############################################################ -->
						<!-- Grid de Clientes tab BLOQUEIO-->
						<!-- ############################################################ -->

						<p:dataTable id="pnlListCardBloq" var="gridBloq"
							value="#{GerBloqBean.bloqLstGrid}"
							emptyMessage="Vazío - Informe um CPF no campo acima e clique em buscar."
							style="margin-top:20px; position: auto" paginator="true"
							selectionMode="single" selection="#{GerBloqBean.bloqSelGrid}"
							rowKey="#{gridBloq.numerocomanda}">

							<p:ajax event="rowSelect"
								listener="#{GerBloqBean.loadCartaoAnt()}" />

							<p:column filterBy="#{gridBloq.numerocomanda}"
								sortBy="numerocomanda" headerText="Nº Cartão"
								filterMatchMode="contains">
								<h:outputText value="#{gridBloq.numerocomanda}" />
							</p:column>

							<p:column filterBy="#{gridBloq.cpf}" sortBy="cpf"
								headerText="CPF do Cliente" filterMatchMode="contains">
								<h:outputText value="#{gridBloq.cpf}" />
							</p:column>

							<p:column filterBy="#{gridBloq.nome}" sortBy="nome"
								headerText="Nome do Cliente" filterMatchMode="contains">
								<h:outputText value="#{gridBloq.nome}" />
							</p:column>

							<p:column filterBy="#{gridBloq.idpedido}" sortBy="idpedido"
								headerText="Nº Registro" filterMatchMode="contains">
								<h:outputText value="#{gridBloq.idpedido}" />
							</p:column>

							<p:column sortBy="datacriacao" headerText="Data ">
								<h:outputText value="#{gridBloq.datacriacao}">
									<f:convertDateTime locale="pt_BR" pattern="dd/MM/yyyy" />
								</h:outputText>
							</p:column>

							<p:column filterBy="#{gridBloq.horacriacao}" sortBy="horacriacao"
								headerText="Hora" filterMatchMode="contains">
								<h:outputText value="#{gridBloq.horacriacao}" />
							</p:column>
						</p:dataTable>

						<p:separator />
						<p:commandButton id="btnTrocar" value="Trocar" ajax="false"
							icon="ui-icon-disk" update=":formBloqueio"
							action="#{GerBloqBean.btnTrocar()}" />
					</p:panel>
				</h:form>
			</p:tab>
		</p:tabView>
	</ui:define>
</ui:decorate>
</html>